<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('/', 'Manage\IndexController@root');
/****test测试区域satrt*******/
Route::get('many/add', 'Doctor\ManageController@test');
/****test测试区域end*******/
Route::group(['prefix' => 'manage/auth'], function () {
    // 登录页面
    Route::get('login', 'Auth\LoginController@manageLoginForm')->middleware('scene')->name('manage.login');
    // 登录接口
    Route::post('login', 'Auth\LoginController@login')->middleware('scene');
    // 注销页面
    Route::get('logout', 'Auth\LoginController@logout')->name('manage.logout');
});

//指尖动态血糖跳转(为了不让中间件验证登陆)⬇
Route::get('manage/reportPrint', 'Dynamic\SamGlucoseController@reportPrint')->name('manage.view.reportPrint');

Route::group([
    'prefix' => 'manage',
    'middleware' => 'auth:doctors'
], function () {
    //指尖动态血糖跳转⬇
    Route::get('bloodsugar', 'Manage\BloodsugarController@bloodsugar')->name('manage.view.bloodsugar');

    //打印报告跳转⬇
    //Route::get('reportPrint', 'Dynamic\SamGlucoseController@reportPrint')->name('manage.view.reportPrint');
    //添加打印报告的数据
    Route::post('addReportInfo', 'Dynamic\SamGlucoseController@addReportInfo');

    Route::group(['middleware' => 'scene'], function () {
        Route::get('index', 'Manage\IndexController@index')->name('manage.view.index');
        Route::get('store', 'Manage\IndexController@store')->name('manage.view.store');
        Route::get('search', 'Manage\IndexController@search')->name('manage.view.search');
        Route::get('subsequent', 'Manage\IndexController@subsequent')->name('manage.view.subsequent');
    });

    //  患者信息
    Route::group(['prefix' => 'patient'], function () {
        //添加复诊
        Route::get('edit', 'Manage\PatientController@edit')->name('patient.edit');

        Route::post('update', 'Manage\PatientController@update')->name('patient.update');
    });

    //  病历信息
    Route::group(['prefix' => 'record'], function () {

        //  病历列表
        Route::get('list', 'Manage\RecordController@index')->name('record.list');
        Route::get('list/{patient}', 'Manage\RecordController@patient')->name('record.patient')
             ->where('patient', '[0-9]+');

        //修改一栏数据
        Route::post('update/column', 'Manage\RecordController@updateColumn')->name('record.update.column');
        //  病历基本信息提交
        Route::post('store', 'Manage\RecordController@store')->name('record.create.first_visit');
        Route::get('edit', 'Manage\RecordController@edit')->name('record.edit');
        Route::post('update', 'Manage\RecordController@update')->name('record.update');
        Route::post('del', 'Manage\RecordController@delete')->name('record.del');
        Route::get('isOneFirst', 'Manage\RecordController@isOneFirst')->name('record.isOneFirst');

        //  创建复诊 页面-tds
        Route::post('subsequent', 'Manage\RecordController@subsequent')->name('record.create.subsequent');
        Route::get('items', 'Manage\RecordController@items')->name('record.items');

        //  病历打印 数据
        Route::get('print', 'Manage\PrintController@printer')->middleware('scene')->name('record.print');
        //  病历打印 页面
        Route::get('print/show', 'Manage\PrintController@show')->middleware('scene')->name('record.print.show');
    });
    //  病历信息结束

    //  主诉
    Route::group(['prefix' => 'complaint'], function () {
        Route::post('store', 'Manage\ComplaintController@store')->name('complaint.store');
        Route::get('edit', 'Manage\ComplaintController@edit')->name('complaint.edit');
        Route::post('update', 'Manage\ComplaintController@update')->name('complaint.update');
    });
    //  主诉结束

    //  现病史
    Route::group(['prefix' => 'hpi'], function () {
        Route::post('store', 'Manage\HpiController@store')->name('hpi.store');
        Route::get('edit', 'Manage\HpiController@edit')->name('hpi.edit');
        Route::post('update', 'Manage\HpiController@update')->name('hpi.update');
        Route::get('symptoms/items', 'Manage\HpiController@items')->name('hpi.items');
    });
    //  现病史结束

    //  现病史组
    Route::group(['prefix' => 'hpiSub'], function () {
        Route::post('store', 'Manage\HpiSubController@store')->name('hpiSub.store');
        Route::get('edit', 'Manage\HpiSubController@edit')->name('hpiSub.edit');
        Route::post('update', 'Manage\HpiSubController@update')->name('hpiSub.update');
        Route::delete('destroy/{hpiSub}', 'Manage\HpiSubController@destroy')->name('hpiSub.destroy')
             ->where('hpiSub', '[1-9][0-9]{0,}');;
    });
    //  现病史组结束

    //  既往史
    Route::group(['prefix' => 'past'], function () {
        Route::post('store', 'Manage\PastHistoryController@store')->name('past.store');
        Route::get('edit', 'Manage\PastHistoryController@edit')->name('past.edit');
        Route::post('update', 'Manage\PastHistoryController@update')->name('past.update');
    });
    //  既往史结束

    //  个人史
    Route::group(['prefix' => 'person'], function () {
        Route::post('store', 'Manage\PersonalHistoryController@store')->name('person.store');
        Route::get('edit', 'Manage\PersonalHistoryController@edit')->name('person.edit');
        Route::post('update', 'Manage\PersonalHistoryController@update')->name('person.update');
    });
    //  个人史结束

    //  月经婚育史项目
    Route::group(['prefix' => 'marriage'], function () {
        Route::post('store', 'Manage\MarriageHistoryController@store')->name('marriage.store');
        Route::get('edit', 'Manage\MarriageHistoryController@edit')->name('marriage.edit');
        Route::post('update', 'Manage\MarriageHistoryController@update')->name('marriage.update');
    });
    //  月经婚育史项目结束

    //  家族史
    Route::group(['prefix' => 'family'], function () {
        Route::post('store', 'Manage\FamilyHistoryController@store')->name('family.store');
        Route::get('edit', 'Manage\FamilyHistoryController@edit')->name('family.edit');
        Route::post('update', 'Manage\FamilyHistoryController@update')->name('family.update');
    });
    //  家族史结束

    //  体格检查项目
    Route::group(['prefix' => 'physical'], function () {
        Route::post('store', 'Manage\PhysicalController@store')->name('physical.store');
        Route::get('edit', 'Manage\PhysicalController@edit')->name('physical.edit');
        Route::post('update', 'Manage\PhysicalController@update')->name('physical.update');
        Route::get('previous', 'Manage\PhysicalController@previous')->name('physical.previous');
    });
    //  体格检查项目结束

    //  辅助检查项目
    Route::group(['prefix' => 'auxiliary'], function () {
        Route::post('store', 'Manage\AuxiliaryController@store')->name('auxiliary.store');
        Route::get('edit', 'Manage\AuxiliaryController@edit')->name('auxiliary.edit');
        Route::post('update', 'Manage\AuxiliaryController@update')->name('auxiliary.update');

        Route::group(['prefix' => 'checks'], function () {
            Route::get('show', 'Manage\AuxiliaryCheckController@show')->name('auxiliary.checks.show');
            Route::get('series', 'Manage\AuxiliaryCheckController@series')->name('auxiliary.checks.series');
            Route::post('store', 'Manage\AuxiliaryCheckController@store')->name('auxiliary.checks.store');
            Route::post('update/{id}', 'Manage\AuxiliaryCheckController@update')->name('auxiliary.checks.update');
        });
    });
    //  辅助检查项目结束

    //  并发症项目
    Route::group(['prefix' => 'complication'], function () {
        Route::post('store', 'Manage\ComplicationController@store')->name('complication.store');
        Route::get('list', 'Manage\ComplicationController@getList')->name('complication.list');
        Route::get('last/list', 'Manage\ComplicationController@getLastList')->name('complication.last.list');
        Route::get('/isSave','Manage\ComplicationController@isSave')->name('complication.isSave');
    });
    //  并发症结束

    //  眼科一般检查
    Route::group(['prefix' => 'ophthalmology'], function () {
        Route::post('store', 'Manage\OphthalmologyController@store')->name('ophthalmology.store');
        Route::get('list', 'Manage\OphthalmologyController@getList')->name('ophthalmology.list');
        Route::get('last/list', 'Manage\OphthalmologyController@getLastList')->name('ophthalmology.last.list');
        Route::get('/isSave','Manage\OphthalmologyController@isSave')->name('ophthalmology.isSave');
    });
    //  眼科一般结束
    //  诊断项目
    Route::group(['prefix' => 'diagnose'], function () {
        Route::post('store', 'Manage\DiagnoseController@store')->name('diagnose.store');
        Route::get('edit', 'Manage\DiagnoseController@edit')->name('diagnose.edit');
        Route::post('update', 'Manage\DiagnoseController@update')->name('diagnose.update');
        Route::get('previous', 'Manage\DiagnoseController@previous')->name('diagnose.previous');
    });
    //  中医诊断
    Route::group(['prefix' => 'cndiagnose'], function () {
        Route::get('list', 'Manage\CnDiagnoseController@index')->name('cndiagnose.list');
        Route::post('store', 'Manage\CnDiagnoseController@store')->name('cndiagnose.store');
        Route::get('show', 'Manage\CnDiagnoseController@show')->name('cndiagnose.show');
        Route::post('update', 'Manage\CnDiagnoseController@update')->name('cndiagnose.update');
        Route::post('destroy/{id}', 'Manage\CnDiagnoseController@destroy')->name('cndiagnose.destroy');
    });
    //  诊断项目结束

    //  处理项目
    Route::group(['prefix' => 'dispose'], function () {
        Route::post('store', 'Manage\DisposeController@store')->name('dispose.store');
        Route::get('edit', 'Manage\DisposeController@edit')->name('dispose.edit');
        Route::post('update', 'Manage\DisposeController@update')->name('dispose.update');
    });
    //  处理项目结束

    //  症状相关
    Route::group(['prefix' => 'symptom'], function () {

        Route::get('list', 'Manage\SymptomController@index')->name('symptom.list');
        //搜索症状
        Route::post('lists', 'Manage\SymptomController@lists');
    });
    //  症状相关结束

    //  药物
    Route::group(['prefix' => 'drug'], function () {
        //  获取药物分组
        Route::get('group', 'Manage\DrugController@group')->name('drug.group');
        Route::get('list', 'Manage\DrugController@index')->name('drug.list');
        Route::post('store', 'Manage\DrugController@store')->name('drug.store');
        Route::get('edit', 'Manage\DrugController@edit')->name('drug.edit');
        Route::post('update', 'Manage\DrugController@update')->name('drug.update');
        Route::get('exists', 'Manage\DrugController@exists')->name('drug.exists');

        Route::get('record', 'Manage\DrugController@drugsOfRecord')->name('drug.record');
    });
    //  药物结束

    //  诊断选项
    Route::group(['prefix' => 'disease'], function () {
        //  获取诊断列表
        Route::get('list', 'Manage\DiseaseController@index')->name('disease.list');
        //  中医疾病类型
        Route::get('cnList', 'Manage\DiseaseController@cnDisease')->name('disease.cn_list');
        //  中医诊断分型
        Route::get('cnType', 'Manage\DiseaseController@cnType')->name('disease.cn_disease');
    });
    //  诊断选项结束

    //  随诊
    Route::group(['prefix' => 'follow'], function () {
        Route::post('store', 'Manage\FollowUpController@store')->name('follow.store');
        Route::get('edit', 'Manage\FollowUpController@edit')->name('follow.edit');
        Route::post('update', 'Manage\FollowUpController@update')->name('follow.update');

        //  获取复诊 随诊初始数据
        Route::get('previous', 'Manage\FollowUpController@previous')->name('follow.previous');
    });
    //  随诊结束

    //  地址联动路由
    Route::group(['prefix' => 'address'], function () {
        Route::get('provinces', 'Manage\CityController@provinces')->name('address.provinces');
        Route::get('cities', 'Manage\CityController@cities')->name('address.cities');
        Route::get('counties', 'Manage\CityController@counties')->name('address.counties');
    });

    Route::group(['prefix' => 'hospital'], function () {
        //  根据医院获取医生
        Route::get('doctors', 'Manage\HospitalController@doctors')->name('hospital.doctors');
        Route::get('doctors/auth/{doctor_id}', 'Manage\HospitalController@withAuth')->name('hospital.auth');
    });

    Route::group(['prefix' => 'doctor'], function () {
        //  根据医院获取医生
        Route::get('/', 'Reservation\DoctorController@index')->name('doctor.index');
        Route::post('/store', 'Reservation\DoctorController@store')->name('doctor.store');
        Route::post('/update', 'Reservation\DoctorController@update')->name('doctor.update');
        Route::post('/destroy', 'Reservation\DoctorController@destroy')->name('doctor.destroy');
        Route::get('/edit/{id}', 'Reservation\DoctorController@edit')->name('doctor.edit');
        Route::get('/getList/byHospital', 'Doctor\DoctorController@getDoctorListByHospital')->name('doctor.getList.ByHospital');

    });

    Route::group(['prefix' => 'eye'], function () {
        Route::get('ground', 'Manage\EyeController@index')->name('eye.ground');
    });
});

Route::group(['prefix' => 'dashboard', 'middleware' => ['auth:doctors', 'scene']], function () {

    Route::get('index', 'Dashboard\IndexController@index')->name('dashboard.index');

});

//  预约
Route::group(['prefix' => 'reserve', 'middleware' => ['auth:doctors', 'reservation']], function () {
    //
    Route::get('/platform', 'Reservation\IndexController@index')->name('reservation.platform');
    Route::get('/manage', 'Reservation\IndexController@manage')->name('reservation.manage');
    Route::get('/create/{patient}', 'Reservation\IndexController@create')->name('reservation.create');

    Route::get('/index', 'Reservation\ReservationController@index')->name('reservation.index');
    Route::post('/store', 'Reservation\ReservationController@store')->name('reservation.store');
    Route::post('/notify', 'Reservation\ReservationController@notify')->name('reservation.notify');
    Route::get('/edit/{id}', 'Reservation\ReservationController@edit')->name('reservation.edit');
    Route::post('/update', 'Reservation\ReservationController@update')->name('reservation.update');
    Route::post('/destroy', 'Reservation\ReservationController@destroy')->name('reservation.destroy');

    //  患者池
    Route::group(['prefix' => 'pool'], function () {
        Route::get('/index', 'Reservation\PoolController@index')->name('reservation.pool.index');
        Route::post('/assignTo', 'Reservation\PoolController@assignTo')->name('reservation.pool.assignTo');
        Route::post('/accept', 'Reservation\PoolController@accept')->name('reservation.pool.accept');
        Route::post('/reject', 'Reservation\PoolController@reject')->name('reservation.pool.reject');
        Route::get('/doctors', 'Reservation\PoolController@doctors')->name('reservation.pool.doctors');
    });

    Route::get('/statistics/situation', 'Reservation\StatisticsController@situation')->name('reservation.statistics');
    Route::get('/statistics/visit', 'Reservation\StatisticsController@visit')->name('reservation.visit');
    //  排班相关
    Route::group(['prefix' => 'schedule'], function () {
        //  获取可选择的诊室
        Route::get('/rooms', 'Reservation\ScheduleController@rooms');

        //  获取医生的排班计划
        Route::get('/plan', 'Reservation\ScheduleController@plan')->name('schedule.plan');
        Route::get('/planInMonthAfterNow', 'Reservation\ScheduleController@planInMonthAfterNow')
             ->name('schedule.planInMonthAfterNow');
        Route::get('/planOfMonth', 'Reservation\ScheduleController@planOfMonth')->name('schedule.planOfMonth');
        Route::get('/storeWithAMonth', 'Reservation\ScheduleController@storeWithAMonth')
             ->name('schedule.storeWithAMonth');

        Route::post('/store', 'Reservation\ScheduleController@store')->name('schedule.store');
        Route::post('/update', 'Reservation\ScheduleController@update')->name('schedule.update');
        Route::post('/destroy', 'Reservation\ScheduleController@destroy')->name('schedule.destroy');
        Route::post('/destroyMonth', 'Reservation\ScheduleController@destroyMonth')->name('schedule.destroyMonth');
    });

    Route::group(['prefix' => 'message'], function () {
        Route::get('/', 'Reservation\MessageController@index')->name('message.index');
        Route::post('/read', 'Reservation\MessageController@read')->name('message.read');
        Route::get('/readAll', 'Reservation\MessageController@readAll')->name('message.readAll');
        Route::get('/unread', 'Reservation\MessageController@unread')->name('message.unread');
    });
});

//Auth::routes();

Route::group(['middleware' => ['auth:doctors']], function () {
    //  搜索相关
    Route::get('/record/search', 'Search\SearchController@index');
    Route::get('/record/export', 'Search\SearchController@export');
});

Route::post('/resources/image/upload', 'ImageController@upload');

Route::group([
    // todo tds ok
    'prefix' => 'manage',
    'middleware' => ['auth:doctors']
], function () {
    //  用户管理相关
    Route::get('/user/index','Doctor\ManageController@index')->name('reservation.user');
    Route::get('/getList', 'Doctor\ManageController@getList');
    Route::get('/hospital/list', 'Doctor\ManageController@getHospitalList');
    Route::get('/hospital/page/list', 'Doctor\ManageController@getHospitalPageList');
    Route::get('/hospital/search', 'Doctor\ManageController@searchHospitalList');
    Route::post('/user/store', 'Doctor\ManageController@store');
    Route::post('/user/edit', 'Doctor\ManageController@edit');
    Route::get('/user/show', 'Doctor\ManageController@show');
    Route::get('/user/tagList', 'Doctor\ManageController@getTagList');
});

/* 上工 */
Route::group([
    'prefix' => 'manage',
    'middleware' => ['CheckSgAble', 'auth:doctors'],
], function () {
    // 上传图片
    Route::post('uploadImgSg','Manage\ImageTransmissionController@uploadImgSg');
    // 删除图片
    Route::match(['get', 'post'], 'deleteImgSg','Manage\ImageTransmissionController@deleteImgSg');
    // 发送
    Route::match(['post'], 'transmission','Manage\ImageTransmissionController@transmission');
    // 查看
    Route::match(['get', 'post'], 'getSgReturnResult','Manage\ImageTransmissionController@getSgReturnResult');
});
Route::group([
    'prefix' => 'manage',
    'middleware' => ['auth:doctors'],
], function () {
    // 删除图片
    Route::match(['get', 'post'], 'deleteImgSg','Manage\ImageTransmissionController@deleteImgSg');

    // test
    Route::match(['get', 'post'], 'test','Manage\ImageTransmissionController@test');
});

Route::group([
    'prefix' => 'test',
    'middleware' => ['auth:doctors']
], function () {
    Route::match(['get', 'post'], 'getList','TestController@getList');
    Route::match(['get', 'post'], 'getVar','TestController@getVar');
});
